#ifndef __GLES_ADAPTOR_H__
#define __GLES_ADAPTOR_H__

#pragma once

#include "RendererGLESCompileConfig.h"

namespace Nezha
{

	// nezha gles context
	struct NZ_GLESContext
	{
	};

	class NEZHA_GLES_ENTRY GLESAdaptor : public SubsystemAdaptor
	{
		friend class RendererGLES;
	public:
		GLESAdaptor();
		virtual ~GLESAdaptor() {}

		// override SubsystemAdaptor
		virtual Subsystems getType() const
		{
			return SYS_RENDERER;
		}

		// override SubsystemAdaptor
		virtual bool initialize(NezhaEngine* engine);

		// override SubsystemAdaptor
		virtual void uninitialize();

		// for implemention override
		virtual void _initialize(NezhaEngine* engine) = 0;

		// for implemention override
		virtual void _uninitialize() = 0;

		virtual NZ_NativeWindow createWindow(EngineConfig& cfg) = 0;

		virtual void destroyWindow(NZ_NativeWindow wnd) = 0;

		virtual void releaseContext(NZ_GLESContext* context) = 0;

		virtual NZ_GLESContext* createContext() = 0;

		virtual void setCurrentContext(NZ_GLESContext* context) = 0;

		virtual void clearContext() = 0;

		virtual void swapFrameBuffer(bool waitVSync) = 0;

		virtual void checkImplError() {}

		NezhaEngine* getEngine()
		{
			return mEngine;
		}

		static GLESAdaptor* GetInstance();

		/** factory func. */
		static GLESAdaptor* CreateInstance(); 

#ifdef NEZHA_OPENGL_ERROR_CHECK

		virtual void checkGLError();

		static const char* msErrorFileName;
		static int msErrorLine;

#endif


NEZHA_INTERNAL:
		EngineConfig* _getEngineConfig()
		{
			return mEngineCfg;
		}

	protected:
		NezhaEngine* mEngine;

	private:
		EngineConfig* mEngineCfg;
	};

}//end namespace Nezha

#endif //end __GLES_ADAPTOR_H__